package com.campol.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;

public class UserPreferences {

	public static final String USER_EMAIL = "email";
	public static final String USER_TOKEN = "token";
	public static final String USER_NAME = "username";
	public static final String USER_PASSWORD = "password";
	
	public static void saveUserPrefs(Context context, String email, String token, String username, String password) {
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
		Editor editor = prefs.edit();
		editor.putString(USER_EMAIL, email);
		editor.putString(USER_TOKEN, token);
		editor.putString(USER_NAME, username);
		editor.putString(USER_PASSWORD, password);
		editor.commit();
	}
	
	public static void saveUserToken(Context context, String token) {
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
		Editor editor = prefs.edit();
		editor.putString(USER_TOKEN, token);
		editor.commit();
	}
	
	public static String getUserToken(Context context) {
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
		return prefs.getString(USER_TOKEN, null);
	}
	
	public static String getUserEmail(Context context) {
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
		return prefs.getString(USER_EMAIL, null);
	}
	
	public static String getUserName(Context context) {
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
		return prefs.getString(USER_NAME, null);
	}
	
	public static String getUserPassword(Context context) {
		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
		return prefs.getString(USER_PASSWORD, null);
	}
}
